//
//  CaSiSongListViewController.m
//  NhomTuan
//
//  Created by Buffalo on 1/30/15.
//  Copyright (c) 2015 Buffalo. All rights reserved.
//

#import "CaSiSongListViewController.h"
#import "CaSiSongListTableViewCell.h"
#import "LoiNhacViewController.h"
@interface CaSiSongListViewController ()

@end

@implementation CaSiSongListViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (UIStatusBarStyle)preferredStatusBarStyle {
    return UIStatusBarStyleLightContent;
}
- (void)viewWillAppear:(BOOL)animated {
    self.tableSingerSongList.delegate = self;
    self.tableSingerSongList.dataSource = self;
    [self.navigationController.navigationBar setBarTintColor:[AppUtils greenColor]];
    self.navigationItem.title = self.singer.name;
    [self.navigationController.navigationBar setTintColor:[UIColor whiteColor]];
    //self.navigationController.navigationItem.title = self.singer.name;
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    NSString *cellId = @"casi_songlist_cell_id";
    CaSiSongListTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellId];
    Song *song = [[Song alloc] initSongInArray:self.singer.songList atIndex:indexPath.row];
    cell.lblSongCode.text = song.code;
    cell.lblSongLyrics.text = song.lyrics;
    cell.lblSongName.text = song.name;
    return cell;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return self.singer.songList.count;
}

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    NSIndexPath *indexPath = [self.tableSingerSongList indexPathForSelectedRow];
    LoiNhacViewController *loiNhacView = (LoiNhacViewController *)segue.destinationViewController;
    loiNhacView.song = [[Song alloc] initSongInArray:self.singer.songList atIndex:indexPath.row];
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
